Migrate C# codegen to blueprint-based model builder#304
Draft
razor-x wants to merge 4 commits into
Draft
Conversation
Replace the OpenAPI-spec parsing port with a generator that depends solely on @seamapi/blueprint, removing every TEMPORARY/TODO output-parity workaround. - smith.ts wires the @seamapi/smith `blueprint` plugin and the csharp plugin reads the resolved blueprint from Metalsmith metadata. - build-model.ts normalizes blueprint resources, endpoints, parameters, and properties into the durable class-model, resolving int vs. float, enum members, inline objects, and discriminated unions directly from the blueprint (no schema traversal). - csharp.ts iterates blueprint.resources / routes and emits action_attempt and event as discriminated unions. - Delete the OpenAPI parsing helpers (lib/openapi/*), the ported types.ts, and schema-modifications.ts. - Regenerate the C# output. Model properties are now uniformly optional and nullable (the blueprint does not carry per-property required/nullable metadata); Api class names derive from the route path. Prune generated files for routes/resources no longer present in the blueprint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ThCbfBhJb4Hydvo8Es4qJA
The blueprint now exposes `isOptional` and `isNullable` on properties. Map them to the two orthogonal C# concepts instead of emitting every model property as optional+nullable: - DataMember IsRequired = !isOptional (payload presence) - C# nullable annotation = isNullable (value may be null) Endpoint parameters are unchanged (they carry isRequired). Bump @seamapi/blueprint to ^0.60.0. The generated output is regenerated and formatted by the Generate CI workflow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ThCbfBhJb4Hydvo8Es4qJA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactored the C# SDK code generator to depend exclusively on the
@seamapi/blueprintspecification instead of the raw OpenAPI schema. This simplifies the build pipeline by eliminating OpenAPI-specific parsing logic while maintaining output compatibility.Key Changes
Rewrote
codegen/lib/build-model.ts: Replaced OpenAPI schema traversal with blueprint-based model building. The new implementation derives types, resources, and properties directly from the normalized blueprint, which already resolves type distinctions (int vs. float, enum members, inline objects, discriminated unions).Simplified
codegen/lib/csharp.ts: Removed OpenAPI type imports and parsing helpers. The codegen now works exclusively with blueprint types (Blueprint,Endpoint).Removed OpenAPI utility modules: Deleted temporary workaround files that ported OpenAPI-specific logic:
codegen/lib/openapi/flatten-obj-schema.tscodegen/lib/openapi/deep-flatten-one-of-and-all-of-schema.tscodegen/lib/openapi/get-parameter-and-response-schema.tscodegen/lib/openapi/get-filtered-routes.tscodegen/lib/types.tscodegen/lib/schema-modifications.tsUpdated
codegen/smith.ts: Changed to use blueprint-based partials from@seamapi/smithinstead of Handlebars-specific utilities.Generated output updates: Regenerated C# model and API classes with nullable reference type annotations (
?) applied consistently across properties. This includes:PhoneSession,Device,AccessCode,AcsUser, etc.)DataMemberattributes to reflectIsRequired = falsefor nullable propertiesClimateSettingSchedulesThermostats,EnrollmentAutomationsUserIdentities,Networks,CredentialProvisioningAutomationsAcs,UnmanagedUsersAcs,UnmanagedAccessGroupsAcs,ClientSessionsV1InstantKeySeam,CredentialPoolsAcs)ClimateSettingSchedule,Location,PartnerResource,ServiceHealth,Network,PhoneRegistration,Pagination)GetRequestinUnmanagedAccessGrants,UnmanagedUserIdentities)offmode in thermostat HVAC settings)Implementation Details
The blueprint-based approach eliminates the need to distinguish between OpenAPI's
int/float,Object/object, and inline enum handling, as the blueprint already normalizes these distinctions. This reduces code complexity and makes the generator more maintainable by depending on a single, well-defined specification format.https://claude.ai/code/session_01ThCbfBhJb4Hydvo8Es4qJA